<template>
   <ul class="catagtory">
     <!-- 谁被激活了 谁变成select -->
     <!-- class 动态用法   :class="{ 类名： 布尔值 }" -->
      <li @click="changeCatagtory(item.id)" :class='{ select: item.id ===  currentCatagtory}' v-for="item in catagtory" :key="item.id">{{ item.name }}</li>
    </ul>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  computed: {
    ...mapState(['catagtory', 'currentCatagtory'])
  },
  methods: {
    ...mapActions(['getCatagtory', 'changeCatagtory'])
  },
  created () {
  // this.$store.dispatch('getCatagtory') // 原始调用方式
    this.getCatagtory()
  }
}
</script>

<style>

</style>
